//
//  AppDimensions.swift
//  gamlify
//
//  Created by Admin on 2024/12/8.
//

import UIKit

struct AppDimensions {
    
    static var shared: AppDimensions = AppDimensions()
    
    private init() {}
    
    // Status bar height
    var statusBarHeight: CGFloat {
        return UIApplication.shared.windows.first?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
    }
    
    // Navigation bar height
    var navigationBarHeight: CGFloat {
        return UINavigationController().navigationBar.frame.height
    }
    
    // Tab bar height
    var tabBarHeight: CGFloat {
        return 62
    }
    
    // tabbar顶部到安全域的高度
    var tabBarTopToSafeArea: CGFloat {
        return tabBarHeight + 8
    }
    
    // Bottom safe area height
    var bottomSafeAreaHeight: CGFloat {
        let window = UIApplication.shared.windows.first
        return window?.safeAreaInsets.bottom ?? 0
    }
    
    // Top safe area height (includes status bar)
    var topSafeAreaHeight: CGFloat {
        let window = UIApplication.shared.windows.first
        return window?.safeAreaInsets.top ?? 0
    }
    
    // Screen width
    var screenWidth: CGFloat {
        return UIScreen.main.bounds.width
    }
    
    // Screen height
    var screenHeight: CGFloat {
        return UIScreen.main.bounds.height
    }
    
    // Is notched device (iPhone X and later)
    var isNotchedDevice: Bool {
        return bottomSafeAreaHeight > 0
    }
    
    // 屏幕底部到tabbar顶部的高度
    var bottomToTabBarTop: CGFloat {
        return bottomSafeAreaHeight + tabBarTopToSafeArea
    }
}

// Usage example:
// let statusBarHeight = AppDimensions.shared.statusBarHeight

// End of file. No additional code.
